package com.cby.springboot.demo.service;

import com.cby.springboot.demo.bean.AdminPermission;
import com.cby.springboot.demo.mapper.AdminPermissionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service("adminPermissionService")
public class AdminPermissionServiceImpl implements AdminPermissionService{

    @Autowired
    AdminPermissionMapper mapper;

    @Override
    public List<AdminPermission> findByName(String name) {
        return mapper.findByName(name);
    }

    @Override
    public AdminPermission findById(int id) {
        return mapper.findById(id);
    }

    @Override
    public List<AdminPermission> findAllById(List<Integer> ids) {
        int size = ids == null ? 0 : ids.size();
        List<AdminPermission> results = new ArrayList<>();
        if(size > 0) {
            for (int i = 0; i < size; i++) {
                results.add(findById(ids.get(i)));
            }
        }
        return results;
    }

    @Override
    public List<AdminPermission> findAll() {
        return mapper.findAll();
    }
}
